package 笔试;

import java.util.*;

public class 释放囚犯 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int P = sc.nextInt();
        int Q = sc.nextInt();
        int[] list = new int[Q+2];
        int[][] lists = new int[Q+2][Q+2];

        for (int i = 1; i < Q+1; i++) {
            list[i]=sc.nextInt();
        }
        Arrays.sort(list,1,Q);
        list[0]=0;
        list[Q+1]=P+1;


        for (int l = 1; l <= Q; l++) {
            for (int i = 1; i+l-1 <= Q; i++) {
                int j=l+i-1;
                lists[i][j] = Integer.MAX_VALUE;
                for (int k = i; k <= j; k++) {
                    lists[i][j] = Math.min(lists[i][j],lists[i][k-1]+lists[k+1][j]+list[j+1]-list[i-1]-2);
                }
            }
        }
        System.out.println(lists[1][Q]);




    }
}
